package com.jd.fruit.model.admin.order;

import com.jd.fruit.common.annotation.Table;
import com.jd.fruit.common.model.BaseModel;
import com.jd.fruit.common.util.StringUtil;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;

/**
 * 商品订单信息
 * 
 * @author admin
 * 
 */
@SuppressWarnings("serial")
@Table("t_order")
public class Order extends BaseModel<Order> {
	
	public static final Order dao = new Order();

	/**
	 * 保存订单信息
	 * 
	 * @param order
	 */
	public void save(Order order) {
		try {
			// UUID订单ID
			order.set("id", StringUtil.getKey());
			//订单编号自增
			//保存
			order.save();
		} catch (Exception e) {
			throw new RuntimeException("保存异常！", e);
		}
	}
	/**
	 * 查询订单信息
	 */
	public Page<Order> list(int pageNumber,int pageSize){ 
		whereParams.clear();
		StringBuffer whereSql=new StringBuffer("FROM `t_order` a  where 1=1 ");
		return this.paginate(pageNumber, pageSize,"SELECT * " ,whereSql.toString(),whereParams.toArray());
	}
	/**
	 * 更新表单数据
	 */
	public int update(String sql,Object paras){
		//user = Db.findById("user", 25).set("name", "James");
		//Db.update("user", user);
		return Db.update(sql, paras);
	}
	@Override
	public void initWhere() {
		// TODO Auto-generated method stub

	}

}
